package GUI;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import Control.Ctr;
import Model.Client;
import Model.Coach;
import Model.Subscription;


public class ClientTable extends AbstractTableModel {

private static final String[] columnNames = { "cID","SSN" , "FName", "LName", "Address", "Phone", "Sessions", "Session Type" };
private Ctr ctr;
private Subscription ch;
private ArrayList<Client> client;
public ClientTable(){
	client = new ArrayList<Client>();
	ctr = new Control.Ctr();
	
	for(Model.Client e : ctr.findAllClient() )
	{client.add(e);
	}
}
public ClientTable(Client c)
{	ctr = new Control.Ctr();
	client = new ArrayList<Client>();
	client.add(c);}

@Override
public int getColumnCount() {
    // 
    return columnNames.length;
}

@Override
public int getRowCount() {
    return client.size();
}

@Override
public String getColumnName(int column) {
    return columnNames[column];
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
     {
    	switch (columnIndex){
    case 0:
        return client.get(rowIndex).getcID();
    case 1:
    	return client.get(rowIndex).getSsn();
    case 2:
        return client.get(rowIndex).getFname();
    case 3:
        return client.get(rowIndex).getLname();
    case 4:
        return client.get(rowIndex).getAddress();
    case 5:
    	return client.get(rowIndex).getPhone();
    case 6:
    	return client.get(rowIndex).getSession();
    case 7:
    	ch = ctr.findBymID(client.get(rowIndex).getmID());
    	return ch.getType();}
    }
    
    return null;
}   
}
